import java.util.Locale;

public class Test {
    //拆分
    public static void main(String[] args) {
        String s = " abdfas df m fs";
        String[] str = s.split(" ");
    }

    //字符串替换
    public static void main6(String[] args) {
        String str1 = "helloworld!";

        //没有修改原来的值
        String ret = str1.replace("ll","@@@");
        System.out.println(ret);

        ret = str1.replace('l','@');
        System.out.println(ret);

        ret = str1.replaceFirst("l","@");
        System.out.println(ret);
    }

    //转化
    public static void main5(String[] args) {
        String str1 = "abcde";
        //字符串转数组
        char[] chArray = str1.toCharArray();
        //数组转字符串
        String str2 = new String(chArray);
        System.out.println(str2);

        //数值和字符串转化
        String str3 = String.valueOf(123);
        System.out.println(str3);
        str3 = String.valueOf(12.34);
        System.out.println(str3);
        str3 = String.valueOf(false);
        System.out.println(str3);

        //大小写转化
        //没有修改原来的值
        System.out.println(str1.toUpperCase());

    }

    //查找
    public static void main4(String[] args) {
        String str1 = "abcde";
        char ch = str1.charAt(1);
        System.out.println(ch);

        for (int i = 0; i < str1.length(); i++) {
            System.out.println(str1.charAt(i));
        }

        System.out.println(str1.indexOf('e'));

    }

    //equals()
    //compareTo
    //equalsIgnoreCase() 忽略大小写
    //compareToIgnoreCase()
    //比较
    public static void main3(String[] args) {
        String str1 = "haha";
        String str2 = "HAha";

        System.out.println(str1.equals(str2));
        System.out.println(str1.compareTo(str2));

        System.out.println(str1.equalsIgnoreCase(str2));
        System.out.println(str1.compareToIgnoreCase(str2));
    }

    //length()
    //isEmpty()
    public static void main2(String[] args) {
        String str1 = "hello";
        System.out.println(str1.length());
        int[] array = {1,2,3};
        System.out.println(array.length);//属性

        String str2 = "";
        System.out.println(str2.length());
        System.out.println(str2.isEmpty());//表示这个对象里面没有字符
        String str3 = null;//表示这个引用不指向任何对象

        System.out.println("haha".length());
        System.out.println("a");
    }

    public static void main1(String[] args) {
        String str1 = "hello";
        String str2 = new String(str1);//str2与str1指向同一个对象

        System.out.println(str1);
        System.out.println(str2);

        //Java中的字符串没有'\0'
        char[] values = {'h','e','l','l','o'};
        String str3 = new String(values);
        System.out.println(str3);


        //String类中有两个成员变量
        //value数组，引用类型！！
        //hash

        //str1指向一个String对象，
        //对象中的成员value指向一个数组对象，存放字符数组
    }
}
